package com.lzit.smart_canteen.repository;

import com.lzit.smart_canteen.domain.Order;
import org.aspectj.weaver.ast.Or;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

public interface OrderRepository extends JpaRepository<Order,String> {
    Order findOrderByOid(String oid);
    List<Order> findOrdersByUid(Integer uid);
    List<Order> findOrdersByUidAndStatus(Integer uid,String status);
    @Transactional
    @Modifying
    void deleteOrderByOid(String oid);

    @Transactional
    @Modifying
    @Query(value = "UPDATE t_order SET status=?2 WHERE oid=?1", nativeQuery = true)
    void updateStatusByOid(String oid,String status);
}
